home *** CD-ROM | disk | FTP | other *** search
/ Aminet 35 / Aminet 35 (2000)(Schatztruhe)[!][Feb 2000].iso / Aminet / gfx / misc / gnuplot-src.lha / gnuplot-3.7.1src / gnuplot-3.7.1.lha / gnuplot-3.7.1 / win / wgnuplib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-15  |  3.7 KB  |  155 lines

  1. #ifndef lint    )ØSid = "$Id: wgnuplib.c,v 1.1.1.2 1998/04/15 19:23:44 lhecking Exp $";
  2. #endif
  3.  
  4. /* GNUPLOT - win/wgnuplib.c */
  5. /*[
  6.  * Copyright 1992, 1993, 1998   Russell Lang
  7.  *
  8.  * Permission to use, copy, and distribute this software and its
  9.  * documentation for any purpose with or without fee is hereby granted,
  10.  * provided that the above copyright notice appear in all copies and
  11.  * that both that copyright notice and this permission notice appear
  12.  * in supporting documentation.
  13.  *
  14.  * Permission to modify the software is granted, but not the right to
  15.  * distribute the complete modified source code.  Modifications are to
  16.  * be distributed as patches to the released version.  Permission to
  17.  * distribute binaries produced by compiling modified sources is granted,
  18.  * provided you
  19.  *   1. distribute the corresponding source modifications from the
  20.  *    released version in the form of a patch file along with the binaries,
  21.  *   2. add special version identification to distinguish your version
  22.  *    in addition to the base release version number,
  23.  *   3. provide your name and address as the primary contact for the
  24.  *    support of your modified version, and
  25.  *   4. retain our contact information in regard to use of the base
  26.  *    software.
  27.  * Permission to distribute the released version of the source code along
  28.  * with corresponding source modifications in the form of a patch file is
  29.  * granted with same provisions 2 through 4 for binary distributions.
  30.  *
  31.  * This software is provided "as is" without express or implied warranty
  32.  * to the extent permitted by applicable law.
  33. ]*/
  34.  
  35. /*
  36.  * AUTHORS
  37.  * 
  38.  *   Russell Lang
  39.  * 
  40.  * Send your comments or suggestions to 
  41.  *  info-gnuplot@dartmouth.edu.
  42.  * This is a mailing list; to join it send a note to 
  43.  *  majordomo@dartmouth.edu.  
  44.  * Send bug reports to
  45.  *  bug-gnuplot@dartmouth.edu.
  46.  */
  47.  
  48. #define STRICT
  49. #include <ctype.h>
  50. #include <windows.h>
  51. #include <windowsx.h>
  52. #include "wgnuplib.h"
  53. #include "wresourc.h"
  54. #include "wcommon.h"
  55.  
  56. HINSTANCE hdllInstance;
  57. LPSTR szParentClass = "wgnuplot_parent";
  58. LPSTR szTextClass = "wgnuplot_text";
  59. LPSTR szPauseClass = "wgnuplot_pause";
  60. LPSTR szGraphClass = "wgnuplot_graph";
  61.  
  62. /* Window ID */
  63. struct WID {
  64.     BOOL       used;
  65.     HWND       hwnd;
  66.     void FAR * ptr;
  67. };
  68. struct WID *widptr = NULL;
  69. unsigned int nwid = 0;
  70. HLOCAL hwid = 0;
  71.  
  72. #ifdef __DLL__
  73. int WDPROC
  74. LibMain(HINSTANCE hInstance, WORD wDataSeg, WORD wHeapSize, LPSTR lpszCmdLine)
  75. {
  76.     hdllInstance = hInstance;
  77.     return 1;
  78. }
  79.  
  80. int WDPROC
  81. WEP(int nParam)
  82. {
  83.     return 1;
  84. }
  85.  
  86. BOOL WDPROC
  87. CheckWGNUPLOTVersion(LPSTR str)
  88. {
  89. char mess[256];
  90. LPSTR version;
  91.     version = WGNUPLOTVERSION;
  92.     if (lstrcmp(str,version)) {
  93.         wsprintf(mess,"Incorrect DLL version\nExpected version   %s\nThis is version   %s",str,version);
  94.         MessageBox(NULL, mess , "WGNUPLOT.DLL", MB_OK | MB_ICONSTOP | MB_TASKMODAL);
  95.         return TRUE;
  96.     }
  97.     return FALSE;    /* Correct version */
  98. }
  99. #endif /* __DLL__ */
  100.  
  101. void NEAR *
  102. LocalAllocPtr(UINT flags, UINT size)
  103. {
  104. HLOCAL hlocal;
  105.     hlocal = LocalAlloc(flags, size+1);
  106.     return (char *)LocalLock(hlocal);
  107. }
  108.  
  109. void
  110. LocalFreePtr(void NEAR *ptr)
  111. {
  112. HLOCAL hlocal;
  113.     hlocal = LocalHandle(ptr);
  114.     LocalUnlock(hlocal);
  115.     LocalFree(hlocal);
  116.     return;
  117. }
  118.  
  119.  
  120. /* ascii to int */
  121. /* returns:
  122.  *  A pointer to character past int if successful,
  123.  *  otherwise NULL on failure.
  124.  *  convert int is stored at pval.
  125.  */
  126. LPSTR
  127. GetInt(LPSTR str, LPINT pval)
  128. {
  129. int val = 0;
  130. BOOL negative = FALSE;
  131. BOOL success = FALSE;
  132. int ch;
  133.     if (!str)
  134.         return NULL;
  135.     while ( (ch = *str)!=0 && isspace(ch) )
  136.         str++;
  137.     if (ch == '-') {
  138.         negative = TRUE;
  139.         str++;
  140.     }
  141.     while ( (ch = *str)!=0 && isdigit(ch) ) {
  142.         success = TRUE;
  143.         val = val * 10 + (ch - '0');
  144.         str++;
  145.     }
  146.     if (success) {
  147.         if (negative)
  148.             val = -val;
  149.         *pval = val;
  150.         return str;
  151.     }
  152.     return NULL;
  153. }
  154.  
  155.